# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Josef Fröhle <github@josef-froehle.de>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libspf2
pkgver=1.2.10
pkgrel=4
pkgdesc="Sender Policy Framework library, a part of the SPF/SRS protocol pair."
url="https://wiki.gnome.org/Projects/Libsecret"
arch="all"
license="LGPL-2.1-or-later OR BSD-2-Clause"
subpackages="$pkgname-dev $pkgname-tools"
makedepends="autoconf automake libtool"
source="http://www.libspf2.org/spf/$pkgname-$pkgver.tar.gz
	00001.patch
	00002.patch
	netdb_success.patch
	musl-res_close.patch
	fix-gcc-variadic-macros.patch
	"

prepare() {
	cd "$builddir"
	update_config_sub
	rm -r src/libreplace
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i ;;
		esac
	done
	libtoolize --force && aclocal && automake --add-missing && autoconf \
		&& autoheader
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

tools() {
	pkgdesc="SPF daemon and command-line utility"
	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/sbin
	mv "$pkgdir"/usr/bin/spfquery "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/spfd "$subpkgdir"/usr/sbin
	rm -fr "$pkgdir"/usr/bin
}

sha512sums="162ce382628c6fcadac3e11f5a12442db622bb23f7ec503e16f5ba7fc88afdd777bce6b093c12a58210355985fd11b74b140f08fab347334d82d953dd183b130  libspf2-1.2.10.tar.gz
3b9bff9b5a5b95f6722f86a43373b0c84cbb79a4509cf0c73486612c0a1b33587bb0b42966b0d2e3a317e4d7a730091fa444bd1258afd06bb3553c4a96d3ee34  00001.patch
18ddfe106b652e2fb9e36a9f1743fc7cecf38530da65a06ac892b60d2c430aaad657f5653495950d4af4b9833826366b79e629937498e5ce7f6af716303221c4  00002.patch
033dd1e959004f7a1026fb1de73813e934560101e04897297e468918ee28e4d7d0f271d6f05d984db22dd43e097f6aa133df18d11419b085d89db89b120750c9  netdb_success.patch
4fb8a28a667d8fe54a48fa89230446b758c6d532866ee26e8b9ef3032f6e0993ec19a2cc2fb265d18d259e35de6fe66183763bbc69c424de70ad8fe0dbcf7a2f  musl-res_close.patch
2face288cfb2cbcfced0f6d47f905b9efdccf696de780892c4e36b134bb4dbe77416b42f42f8ccb16da47551d800fe037899324dec33e140fb8cea0f201abd74  fix-gcc-variadic-macros.patch"
